package com.lml.jdk8.localdate.java8Time;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author luomingliang
 * @date 2023/7/16 20:12
 */
public class DurationDemo {

    public static void main(String[] args) {
        LocalDateTime start = LocalDateTime.of(2020, 11, 11, 10, 10, 10);
        LocalDateTime end = LocalDateTime.of(2020, 11, 11, 11, 11, 11);
        //1.得到Duration对象
        Duration duration = Duration.between(start, end);
        //2.获取两个时间对象间隔的信息
        System.out.println("duration.toDays() = " + duration.toDays());
        System.out.println("duration.toHours() = " + duration.toHours());
        System.out.println("duration.toMinutes() = " + duration.toMinutes());
        System.out.println("duration.toMillis() = " + duration.toMillis());
        System.out.println("duration.toNanos() = " + duration.toNanos());
    }
}
